<?php

class Default_Model_Partner extends Zend_Db_Table_Abstract
{
    protected $_name = 'partner';
    public function getAllData(){
        $query = $this->select()
                        ->from($this->_name)
                        ->order('partnerId ASC');
        return $this->fetchAll($query);
    }
    public function getDataById($partnerId){
    	$query = $this->select()
                        ->from($this->_name)
                        ->where('partnerId = ?',$partnerId);
        return $this->fetchRow($query);
    }
    public function getDataByPartnerList($partnerList){
        $query = $this->select()
                        ->from(array('p'=>$this->_name))
                        ->where('p.partnerId IN '.$partnerList)
                        ->where('p.status = ?',1)
                        ->order('p.partnerId ASC');
        return $this->fetchAll($query);
    }
    public function deleteData($partnerId){
        $this->delete('partnerId = "' . $partnerId.'"');
    }
    public function updateData($partnerId, $partnerName, $partnerImg, $openDate, $repair = '',  $status){
    	$data = array('partnerName' => $partnerName, 
                    
                    'partnerImg' => $partnerImg, 
                    'openDate' => $openDate, 
                   
            
                    'status' => $status);
        return $this->update($data, 'partnerId = "' . $partnerId.'"');
    }
    public function addData($partnerId, $partnerName,$partnerImg, $openDate, $createUser, $createDate, $status){
    	$data = array('partnerId' => $partnerId, 
                    'partnerName' => $partnerName,
                    'partnerImg' => $partnerImg, 
                    'openDate' => $openDate, 
                    'createUser' => $createUser,
                    'status' => $status);
        $idAdd = $this->insert($data);
        return $idAdd;
    }
     public function getDataByPartnerName($partnerName){
    	$query = $this->select()
                        ->from($this->_name)
                        ->where('partnerName = ?',$partnerName);
        return $this->fetchRow($query);
    }
}